package com.tjetc.dao.impl;

import com.tjetc.dao.AmenitiesDao;
import com.tjetc.pojo.vo.AmenitiesNameVO;
import com.tjetc.utils.DruidUtils;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import java.util.List;

/**
 * @Author: itda
 * @Date: 2024/5/11 9:01
 * @Description: AmenitiesDaoImpl
 */
public class AmenitiesDaoImpl implements AmenitiesDao {
    @Override
    public void deleteByHotelId(Long hotelId) throws Exception {
        DruidUtils.r1.update(DruidUtils.getConnection(), "delete from amenities where hotel_id = ?", hotelId);
    }

    @Override
    public List<AmenitiesNameVO> getByHotelId(Long hotelId) throws Exception {
        return DruidUtils.r2.query("select name from amenities where hotel_id = ?", new BeanListHandler<>(AmenitiesNameVO.class), hotelId);
    }
}
